#override("title")
SpringWind - 场地列表
#end
#override("css")
<link href="#springUrl('/static/css/plugins/bootstrap-table/bootstrap-table.min.css')" rel="stylesheet">

#end
#override("breadcrumb")
<li><a>评分系统</a></li><li class="active"><strong>场地列表</strong></li><li class="active"><strong id="province">$!{province}</strong></li><li class="active"><strong id="city">$!{city}</strong></li>
#end
#override("content")
<div class="row">
    <input type="hidden" name="provinceId" value="$!{provinceId}">
    <input type="hidden" name="cityId" value="$!{cityId}">
    <input type="hidden" name="province" value="$!{province}">
    <input type="hidden" name="city" value="$!{city}">
	<div class="ibox-content text-left form-inline" style="background: #F3F3F4;">
		<div class="input-group">
			<label class="text-left">场地id:<input type="text" class="" id="sid"></label>
		</div>&nbsp;
		<div class="input-group">
			<label  class="text-left">场地名称:<input type="text" class="" id="sName"></label>
		</div>
		<div class="input-group">
			<button type="button" class="btn btn-info" id="querySite" onclick="querySource($('#sid').val(),$('#sName').val())">查询</button>
		</div>
		<div class="input-group">
             <a id="addSite" class="btn btn-primary"  title="添加">添加</a>
		</div>
	</div>

</div>
<div class="row">
    <div class="col-sm-12">
        <table id="dataTable"></table>
    </div>
</div>
#end
#override("js")
<script src="#springUrl('/static/js/plugins/bootstrap-table/bootstrap.min.js')"></script>
<script src="#springUrl('/static/js/plugins/bootstrap-table/bootstrap-table.min.js')"></script>
<script src="#springUrl('/static/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js')"></script>
<script src="#springUrl('/static/plugins/layer-v2.2/layer/layer.js')"></script>
<script src="#springUrl('/static/js/base_list.js')"></script>
<script src="#springUrl('/static/js/common.js')"></script>
<script type="text/javascript">
 var  province=$("input[name='provinceId']").val();
 var city=$("input[name='cityId']").val();
 var dataUrl="#springUrl('/site/getSiteList/"+province+"/"+city+"')";
 /*var data = $('#dataTable').bootstrapTable('getData');*/
 var dataColumns = [{
		field: 'id',
		title: '场地编号'
	}, {
		field: 'siteName',
		title: '场地名称'
	}, {
		field: 'description',
		title: '简介'
	},
    {
        field: 'score',
        title: '得分'
    }, {
         field: 'create_time',
         title: '创建时间',
         formatter: function (value, row, index) {
             return formatDate(row.create_time);
         }
    }, {
         field: 'status',
         title: '状态',
         formatter: function (value, row, index) {
             if(row.status==2){
                 return '<span style="color: red">待审批</span>';
             }else if(row.status==3){
                 return "<a style='color: green' onclick='examine("+JSON.stringify(row)+")'>审批通过</a>";
             }else if(row.status==1){
                 return '<span style="color: orange">未提交</span>';
             }else if(row.status==-1){
                 return "<a style='color: blue' onclick='examine("+JSON.stringify(row)+")'>审批不通过</a>";
             }
         }
     },  {
    title: '操作',
    formatter: function (value, row, index) {
        var id = row.id;
		if(row.status==1||row.status==-1){
            return'<a class="btn btn-xs btn-warning" title="修改"  href="#springUrl("/site/edit/' + id +'")"><i class="fa fa-pencil"></i>修改</a> '
                +'<a class="btn btn-xs btn-success" title="分数统计" href="#springUrl("/siteSource/view/' + id +'")"><i class="fa fa-edit"></i>分数统计</a>'
                +'<a class="btn btn-xs btn-info" title="污染物" href="#springUrl("/siteSource/add/' + id +'/0'+'")"><i class="fa fa-pencil"></i>污染物</a> '
                +'<a class="btn btn-xs btn-danger" title="污染途径" href="#springUrl("/groundWater/index/' + id+'/0' +'")"><i class="fa fa-remove"></i>污染途径</a> '
                +'<a class="btn btn-xs btn-primary" title="提交审批" onclick="submitExamine(' + "'" + id + "'" + ')" ><i class="fa fa-check"></i>提交审批</a>'
                + '<a class="btn btn-xs btn-danger" title="删除" onclick="delSite(' + "'" + id + "'" + ')"><i class="fa fa-remove"></i>删除</a>';
		}else {
            return'<a class="btn btn-xs btn-warning" title="查看"  href="#springUrl("/examine/details/' + id +'")"><i class="fa fa-pencil"></i>查看</a> '
                +'<a class="btn btn-xs btn-success" title="分数统计" href="#springUrl("/siteSource/view/' + id +'")"><i class="fa fa-edit"></i>分数统计</a>'
                +'<a class="btn btn-xs btn-info" title="污染物" href="#springUrl("/examine/source/' + id +'/0'+'")"><i class="fa fa-pencil"></i>污染物</a> '
                +'<a class="btn btn-xs btn-danger" title="污染途径" href="#springUrl("/examine/ground/' + id+'/0' +'")"><i class="fa fa-remove"></i>污染途径</a> ';
		}

    }
}];
function dataQueryParams(params) {
	return {
		_size: params.limit,  //页面大小
		_index: params.offset, //页码
		sid:$('#sid').val(),
		name:$('#sName').val(),
        province:province,
		city:city
	};
}
function SiteDetail() {
    var title = "分数评比";
    var url = "#springUrl('/site/detail.html')";
    layer.open({
        type: 2,
        title: title,
        shadeClose: true,
        shade: 0.8,
        area: ['600px', '480px'],
        fix: false,
        maxmin: true,
        content: url
    });
}
/*function delSource(id) {
    //询问框
    layer.confirm('确定删除吗？', {
        btn: ['确定', '取消'] //按钮
    }, function () {
        $.ajax({
            type: "POST",
            url: "#",
            datatype: "text",
            success: function (data) {
                if(data == 'true'){
                    $('#dataTable').bootstrapTable('refresh',{url:dataUrl});
                }
                layer.closeAll();
            }
        });
    }, function () {
        return;
    });
}*/

function examine(row) {
    layer.open({
        type: 1,
        title:'审批意见',
        // skin: 'layui-layer-rim', //加上边框
        area: ['450px', '270px'], //宽高
        content: '<textarea id="idea" style="height: 100%;width: 100%;border: none">'+row.idea+'</textarea>',
    });
}

//提交审批
function submitExamine(siteId) {
    //询问框
    layer.confirm('提交后不可更改，确定提交吗？', {
        btn: ['确定', '取消'] //按钮
    }, function () {
        $.ajax({
            type: "POST",
            url: "#springUrl('/site/examine/')" + siteId,
            datatype: "text",
            success: function (data) {
                if(data == 'true'){
                    $('#dataTable').bootstrapTable('refresh',{url:dataUrl});
                }
                layer.closeAll();
            }
        });
    }, function () {
        return;
    });
}


 //查询功能
 function querySource(id,name) {
     $('#dataTable').bootstrapTable('refresh',{
         url:"#springUrl('/site/querySiteList')",
		// method:'post'
	 });

 }

!function () {
    var provinceId=$("input[name='provinceId']").val();
    var cityId=$("input[name='cityId']").val();
    $('#addSite').attr('href','#springUrl("/site/add/'+provinceId+'/'+cityId+'")');
}();
function editSource(id) {
   	var title = "查看场地";
   	var url = "#springUrl('/site/edit.html')";
   	if(id!=null){
   		url = url + "?id=" + id;
   	}
    layer.open({
        type: 2,
        title: title,
        shadeClose: true,
        shade: 0.8,
        area: ['550px', '430px'],
        fix: false,
        maxmin: true,
        content: url
    });
}
 function delSite(siteId) {
     //询问框
     layer.confirm('确定删除吗？', {
         btn: ['确定', '取消'] //按钮
     }, function () {
         $.ajax({
             type: "POST",
             url: "#springUrl('/site/delSite/')" + siteId,
             datatype: "text",
             success: function (data) {
                 if(data == 'true'){
                     $('#dataTable').bootstrapTable('refresh',{url:dataUrl});
                 }
                 layer.closeAll();
             }
         });
     }, function () {
         return;
     });
 }


</script>
#end
#extends("/common/framework.html")
